package messages.elevator;

import state.group.HallCall;
import messages.BaseMessage;
import messages.MessageType;

public class HallCallAssignmentMessage extends BaseMessage {

    private HallCall call;
    
    public HallCallAssignmentMessage(byte[] data)
    {
        super(data);
        call = new HallCall(data[1], data[2]);
    }
    
    public HallCallAssignmentMessage(HallCall call)
    {
        super (null);
        this.call = call;
    }
    
    public HallCall getHallCall()
    {
        return call;
    }

    @Override
    public byte[] toByteArray()
    {
        byte[] retVal = new byte[getMessageSize()];
        retVal[0] = getMessageType().getIdentifier();
        retVal[1] = call.getFloor();
        retVal[2] = call.getDirection();
        return retVal;
    }

    @Override
    public MessageType getMessageType()
    {
        return MessageType.HallCallAssignmentMessage;
    }

    @Override
    public int getMessageSize()
    {
        return 3;
    }

}
